# @Time :2021/12/17 下午9:33
# @Author : The Kite Runner
# @File : say_something.py

"""
                                        QQ空间抓取
    用到的模块:
    1.requests # 第三方请求模块 sudo pip3 install requests
    2.ftfy 用于解密 安装   sudo pip3 install ftfy
"""
"""
本文处理的加密字体
q_namecard"  link="nameCard_2281380202" target="_blank" 
href="http://user.qzone.qq.com/2281380202">æ¢ä¿æ¶</a>&nbsp; : è¿ä¿©å°å­©å±ä¹±å«ï¼æ²¡äºåä¸
æªä½ ä»¬<div class="comments-op"><span  class=" ui-mr10 state" >8æ18æ¥ 
"""
import requests
import ftfy  # 第三方库

class SaySomething:
    def __init__(self, url, headers):
        self.url = url
        self.headers = headers

    def request_(self):
        """
        请求函数
        """
        resp = requests.get(url=self.url, headers=self.headers).text
        print(resp)  # 未解密的字符
        resp = ftfy.fix_text(resp)  # 将加密后的字符转换为UTF-8字符

        return resp


if __name__ == '__main__':
    # 替换为要抓取的好友说说连接诶
    url = 'https://user.qzone.qq.com/proxy/domain/ic2.qzone.qq.com/cgi-bin/feeds/feeds_html_module?g_iframeUser=1&i_uin=2281380202&i_login_uin=1693057533&mode=4&previewV8=1&style=25&version=8&needDelOpr=true&transparence=true&hideExtend=false&showcount=5&MORE_FEEDS_CGI=http%3A%2F%2Fic2.s21.qzone.qq.com%2Fcgi-bin%2Ffeeds%2Ffeeds_html_act_all&refer=2&paramstring=os-winxp|0'

    # headers 替换为自己链接里面的标头
    headers = {
        'cookie': 'RK=9qahbWqaP2; ptcz=b7846f93d7f04535937113d1c95507e8624da024cd6e43e946c98f142e9cdd30; pgv_pvid=5230868039; __Q_w_s__QZN_TodoMsgCnt=1; Loading=Yes; qz_screen=1536x864; QZ_FE_WEBP_SUPPORT=1; __layoutStat=18; uin=o1693057533; skey=@d3ogdf0AO; p_uin=o1693057533; pgv_info=ssid=s7422256558; pt4_token=*14mYzwvVicJzFgcstZ0pkTxpKbLtdpP6xlFj7PqZz4_; p_skey=-BA1INTrOHQp8xOR9aqHXzacLHJUgcE0M1umMyXLE*g_; cpu_performance_v8=6; rv2=8085C80A4A139990F2B980CABB21C44B573E818AE4A9353D18; property20=F5F0CFCF9492895328EAD3FED6CFDA62CABA28D858E2AAFFFA16E56223E3AEA708A1B3233939A2E2',
        'pragma': 'no-cache',
        'referer': 'https://user.qzone.qq.com/2281380202',
        'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="96", "Google Chrome";v="96"',
        'sec-ch-ua-mobile': '?0',
        'sec-ch-ua-platform': '"Windows"',
        'sec-fetch-dest': 'iframe',
        'sec-fetch-mode': 'navigate',
        'sec-fetch-site': 'same-origin',
        'upgrade-insecure-requests': '1',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36',
    }
    say = SaySomething(url, headers)
    print(say.request_())
